using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;

namespace Matrix.Configuration
{
    /// <summary>
    /// 配置项仓储接口
    /// </summary>
    public interface IConfigurationRepository : IRepository<ConfigurationItem, Guid>
    {
        /// <summary>
        /// 根据租户ID、命名空间和名称获取配置项
        /// </summary>
        Task<ConfigurationItem?> GetByNameAsync(
            Guid? tenantId,
            string @namespace,
            string name,
            bool includeDetails = true,
            CancellationToken cancellationToken = default);

        /// <summary>
        /// 根据租户ID和命名空间获取配置项列表
        /// </summary>
        Task<List<ConfigurationItem>> GetListByNamespaceAsync(
            Guid? tenantId,
            string @namespace,
            bool includeDetails = true,
            CancellationToken cancellationToken = default);

        /// <summary>
        /// 根据租户ID获取所有配置项
        /// </summary>
        Task<List<ConfigurationItem>> GetListByTenantAsync(
            Guid? tenantId,
            bool includeDetails = true,
            CancellationToken cancellationToken = default);

        /// <summary>
        /// 根据键名模糊搜索配置项
        /// </summary>
        Task<List<ConfigurationItem>> GetListByKeywordAsync(
            Guid? tenantId,
            string keyword,
            bool includeDetails = true,
            CancellationToken cancellationToken = default);

        /// <summary>
        /// 检查配置项是否存在
        /// </summary>
        Task<bool> ExistsAsync(
            Guid? tenantId,
            string @namespace,
            string name,
            CancellationToken cancellationToken = default);

        /// <summary>
        /// 删除指定租户的所有配置项
        /// </summary>
        Task DeleteAllByTenantAsync(
            Guid? tenantId,
            CancellationToken cancellationToken = default);

        /// <summary>
        /// 批量删除过期的缓存项
        /// </summary>
        Task<int> DeleteExpiredCacheItemsAsync(
            CancellationToken cancellationToken = default);
    }
}